package com.gxa.jjty.cjr.controller;

import com.gxa.jjty.cjr.service.HealthyService;
import com.gxa.jjty.core.exception.BusinessException;
import com.gxa.jjty.core.pojo.Healthy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @author : 宸濯
 * Date: 2021/12/06 16:42
 * Description:
 * Version: V1.0
 */
@Api(tags = "健康数据api")
@RestController
@RequestMapping("/healthy")
public class HealthyController {

    @Autowired
    HealthyService healthyService;

    @PostMapping("/upsert")
    @ApiOperation("添加/修改用户健康数据")
    public Map<String,Object> upsert(@Validated Healthy healthy) throws BusinessException {
        return healthyService.upsert(healthy);
    }

    @PostMapping("/findById")
    @ApiOperation("根据用户id查询用户健康数据")
    public Map<String,Object> findById(Long id) throws BusinessException {
        return healthyService.findById(id);
    }
}
